<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core">
	<f:view>
		<h:form id='edit_brand_form' method="POST" enctype="multipart/form-data">
			<h:head>
	<f:loadBundle basename="messages" var="msgs" />
	<title><h:outputText value="#{msgs.title}" /></title>
	
	<script type="text/javascript" src="../../resources/script/jquery.js"></script>
	
	<style type="text/css" title="currentStyle">
		@import "${facesContext.externalContext.requestContextPath}/views/management/css/edit_brand.css";
		@import "${facesContext.externalContext.requestContextPath}/views/css/theme.css";
	</style>
	<script type="text/javascript"
				src="${facesContext.externalContext.requestContextPath}/views/management/scripts/edit_brand.js"></script>
				
	<script type="text/javascript">
		$(document).ready(function () {
			var flag = $('[id="edit_brand_form:brand_flag"]' );
			var flagLabel = $('[id="edit_brand_form:flag_label"]' );
			if(flag.is(':checked'))
			{
				flagLabel.text("Disable");
			}
			else
			{
				flagLabel.text("Enable");
			}
			flag.click(function(){
				if(flag.is(':checked'))
				{
					flagLabel.text("Disable");
					$('[id="edit_brand_form:enable_flag"]' ).val(1);
				}
				else
				{
					flagLabel.text("Enable");
					$('[id="edit_brand_form:enable_flag"]' ).val(0);
				}
			});
		})
		</script>

		</h:head>
		<body>
			<ui:include src="../header/header.xhtml" />
			<br />
			<br />
			<br />

			<h:outputText value="#{msg.create_item_title}" />

			<p></p>
			
			<div id="invisible_div" class="hidden_input">
				<h:inputText id="preview_icon" value="#{editBrandBean.previewIconPath}"></h:inputText>
				<h:inputText id="temp_icon" value="#{editBrandBean.tempIconFilePath}"></h:inputText>
				<h:inputText id="icon" value="#{editBrandBean.icon}"></h:inputText>
				<h:inputText id="mode" value="#{editBrandBean.mode}"></h:inputText>
				<h:inputText id="enable_flag" value="#{editBrandBean.enableFlag}"></h:inputText>
				<h:inputText id="brand_name" value="#{editBrandBean.name}" ></h:inputText>
			</div>

			<div id="div">
				<table class="display" id="brand_table">
					<tr>
						<td><h:outputLabel value="Name" ></h:outputLabel></td>
						<td>
							<h:inputText id="brand_name_edit" disabled="true" value="#{editBrandBean.name}" rendered="#{editBrandBean.mode == 0}">
							</h:inputText>
							<h:inputText id="brand_name_new" value="#{editBrandBean.name}" rendered="#{editBrandBean.mode == 1}">
							</h:inputText>
						</td>
						<td>
						</td>
					</tr>
					<tr>
						<td>
							<h:outputLabel value="Description:">
							</h:outputLabel>
						</td>
						<td>
							<h:inputText value="#{editBrandBean.description}">
							</h:inputText>
						</td>
						<td>
						</td>
					</tr>
					<tr>
						<td><h:outputLabel value="Icon"></h:outputLabel></td>
						<td><h:graphicImage id="icon_image" value="#{editBrandBean.icon}" rendered="#{editBrandBean.icon.length() gt 0}"></h:graphicImage></td>
						<td>
							<h:inputFile id="icon_file" value="#{editBrandBean.iconFile}" onchange="loadBtnOnClick()">
							</h:inputFile>
							<h:commandButton id="load_icon_btn" value="Load" action="#{editBrandBean.loadIconAction}" onclick="return loadIcon()">
							</h:commandButton>
						</td>
					</tr>
					<tr>
						<td>
						<h:outputLabel id="flag_label" value="#{msg.enable}">
						</h:outputLabel>
						<!-- 
						<h:outputLabel id="flag_disable_label" value="Disable" rendered="#{not editBrandBean.enabled}">
						</h:outputLabel>
						 -->
						</td>
						<td><h:selectBooleanCheckbox id="brand_flag"
								value="#{editBrandBean.enabled}" >
							</h:selectBooleanCheckbox></td>
					</tr>
					

					<tr>
						<td><h:commandButton value="#{msg.submit}"
								action="#{editBrandBean.submitAction}" onclick="return loadIcon()">
							</h:commandButton></td>
						<td><h:commandLink value="Back To Brands"
								action="#{editBrandBean.backToItemsAction }" /></td>
					</tr>
				</table>
			</div>
			<p></p>
			<ui:include src="../footer/footer.xhtml" />
		</body>
	</h:form>
</f:view>
</html>
